What is Python __init__()?
192
23-Oct-2025
Updated on 23-Oct-2025
Jk Malhotra
23-Oct-2025Basic Example
When you call
Person("Alice", 25), Python does this behind the scenes:Personobject in memory.__init__(p1, "Alice", 25)to initialize it.What is
self?Example:
Each dog keeps its own
namevalue because ofself.Default and Optional Parameters
You can give parameters default values, just like with normal functions.
__init__()vs Normal Methods__init__()None